<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Edit your profile</title>
    </h:head>
    <h:body>
        <h:form id="editprofileform">
            <p:panel header="Edit your profile">
                <h:panelGrid columns="3" id="editGrid">
                    <p:outputLabel for="name">Username:</p:outputLabel>
                    <p:inputText id="username" value="#{usersView.loggedUser.username}">
                        <p:ajax update="usernamemsg"/>
                    </p:inputText>
                    <p:message id="usernamemsg" for="username" />
                    <p:outputLabel for="name">Name:</p:outputLabel>
                    <p:inputText id="name" value="#{usersView.loggedUser.name}">
                        <p:ajax update="namemsg"/>
                    </p:inputText>
                    <p:message id="namemsg" for="name" />
                    <p:outputLabel for="surname">Surname:</p:outputLabel>
                    <p:inputText id="surname" value="#{usersView.loggedUser.surname}">
                        <p:ajax update="surnamemsg"/>
                    </p:inputText>
                    <p:message id="surnamemsg" for="surname" />

                    <p:outputLabel for="birthdate">Date of birth:</p:outputLabel>
                    <p:calendar id="birthdate" value="#{usersView.loggedUser.dateOfBirth}" pattern="dd-MM-yyyy" mask="true">
                        <p:ajax update="birthmsg"/>
                    </p:calendar>
                    <p:message id="birthmsg" for="birthdate" />

                    <p:outputLabel for="email">Email:</p:outputLabel>
                    <p:inputText id="email" value="#{usersView.loggedUser.email}">
                        <p:ajax update="emailmsg"/>
                    </p:inputText>
                    <p:message id="emailmsg" for="email" />

                    <p:outputLabel for="password">Password:</p:outputLabel>
                    <p:password id="password" value="#{usersView.loggedUser.password}" 
                                feedback="true" match="pwd2" label="Password"/>
                    <p:message for="password" />

                    <p:outputLabel for="pwd2">Confirm Password:</p:outputLabel>
                    <p:password id="pwd2" label="Confirm Password"/>
                    <p:message for="password" />

                    <p:outputLabel for="description">Personal description:</p:outputLabel>
                    <p:inputTextarea id="description" rows="6" cols="33"  value="#{usersView.loggedUser.description}"/>
                </h:panelGrid>
                <p:commandButton id="submitChanges" value="Save" update="editGrid"
                                 action="#{usersView.update()}" />
            </p:panel>
        </h:form>
    </h:body>
</html>

